package com.cx.core.magazine.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.cx.core.magazine.service.MagazineManageService;
import com.li.core.RequestEnvelope;
import com.li.core.ResponseEnvelope;
import com.li.core.actionBase.ActionBase;

public class MagazineManageAction extends ActionBase {

	public ActionForward magazineManaerAction(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ResponseEnvelope rse = null;
		try {

			RequestEnvelope<String, String> rqs = this.splitParameters(request);
			String requestname = rqs.getParameter("actionname");
			MagazineManageService ms = (MagazineManageService) super
					.getBean("magazineManageService");
			if (requestname.equals("REQ_QUERYPERIODBYYEAR")) {
				rse = ms.queryPeriods(rqs);
			} else if (requestname.equals("REQ_QUERYARTICLEBYPERIOD")) {
				rse = ms.queryArticlesByPeriod(rqs);
			}
		} catch (Exception e) {
			e.printStackTrace();
			rse = new ResponseEnvelope<String, String>();
			rse.setAppCode(-1);
			rse.setMessage(e.getMessage());
			rse.setDetalMessage(e.getMessage());
		}
		this.writeResponse(response, rse);
		return null;
	}

}
